package com.four.commodity.controller;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class CommodityQuert extends Thread{
		public static void main(String[] args) {
			String driver = "com.mysql.jdbc.Driver";
			String url = "jdbc:MySQL://127.0.0.1:3306/dianshang?useUnicode=true&characterEncoding=UTF-8";
			String user = "root";
			String password = "123456";
			try{
			   Class.forName(driver);
			      Connection conn = DriverManager.getConnection(url, user, password);
			      if(!conn.isClosed());
			   System.out.println("Succeeded connecting to the Database!");
			      Statement statement = conn.createStatement();

			      ResultSet result = statement.executeQuery("select * from conn");

	         while(result.next()){
	        	 String name = result.getString("descrption");
	        	 System.out.println(result.getString("name") + "\t" + name);
	         }		
			}catch(Exception e){
				e.printStackTrace();
			}	

		}
}

